/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package air_hockey_v2.gui;

import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author matheuscg
 */
public class Creditos extends JFrame {

    private Imagem fundo = new Imagem("/images/creditos.png", 0, 0);
    private Imagem bVoltar = new Imagem("/images/voltarB.png", 540, 500);

    public Creditos() {
        super("Créditos");
        this.setSize(800, 600);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        JPanel panel = new JPanel() {

            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);

                fundo.draw(g);
                bVoltar.draw(g);
            }
        };
        this.getContentPane().add(panel);
        panel.addMouseListener(new OuvinteMouse());
    }

    private class OuvinteMouse extends MouseAdapter {

        @Override
        public void mouseClicked(MouseEvent e) {
            int x = e.getX();
            int y = e.getY();
            if ((x >= bVoltar.getX() && x <= bVoltar.getX() + bVoltar.getWidth()) && (y >= bVoltar.getY() && y <= bVoltar.getY() + bVoltar.getHeight())) {
                dispose();
            }
        }
    }
}
